Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxd: add support for interim Ubuntu releases #219

Merged
merged 9 commits into from
Feb 24, 2023

Conversation

mr-cal
Copy link
Collaborator

@mr-cal mr-cal commented Feb 21, 2023

  • Have you signed the CLA?

Overview

This PR adds support for interim and devel Ubuntu releases with LXD.

Broken into 6 separate commits to speed up review time.

Details

Previously, craft-providers maintained a list of valid LXD images with a simple enum. Now, the remotes.py module has a new dataclass called RemoteImage and a dictionary of valid RemoteImages to track what images are supported.

It is designed in such a way that users can add custom remotes and we'll be able to add support for other bases (like a centos base) without breaking changes.

Usage

For applications using the LxdProvider class (snapcraft, charmcraft, and rockcraft), there are no changes in behavior or usage. You can simply pass in the new release names:

class BuilddBaseAlias(enum.Enum):
    XENIAL = "16.04"
    BIONIC = "18.04"
    FOCAL = "20.04"
    JAMMY = "22.04"
    KINETIC = "22.10"
    LUNAR = "23.04"

For other applications (lpcraft 👀), you'll need to use the replace the old configure_buildd_image_remote() function with the new get_remote_image() function.

Note - the old function configure_build_image_remote() still exists and its behavior is unchanged, except for a deprecation notice.

Example usage

remote_image = lxd.get_remote_image(BuilddBaseAlias.KINETIC.value)

base_configuration = bases.BuilddBase(alias=BuildBaseAlias.KINETIC)

instance = lxd.launch(
    name="my-instance",
    base_configuration=base_configuration,
    image_name=remote_image.image_name,
    image_remote=remote_image.remote_name,
)

TODO

  • break into smaller commits

Sources

(CRAFT-1601)

@mr-cal mr-cal marked this pull request as draft February 21, 2023 21:43
@mr-cal mr-cal force-pushed the lxd-interim-release-support branch 2 times, most recently from f440e2b to 827dfff Compare February 22, 2023 15:09
@mr-cal mr-cal marked this pull request as ready for review February 22, 2023 15:09
@mr-cal mr-cal changed the title (draft) lxd: add support for interim Ubuntu releases lxd: add support for interim Ubuntu releases Feb 22, 2023
@jugmac00
Copy link
Member

From lpcraft side - it works like a charm! Thanks a lot!

@mr-cal mr-cal force-pushed the lxd-interim-release-support branch 2 times, most recently from df69233 to ce86d63 Compare February 23, 2023 15:13
The previous `configure_buildd_image_remote` function now points to the
new method.

Signed-off-by: Callahan Kovacs <[email protected]>
craft_providers/lxd/remotes.py Outdated Show resolved Hide resolved
craft_providers/lxd/lxd_provider.py Outdated Show resolved Hide resolved
@mr-cal mr-cal merged commit c428f4b into canonical:main Feb 24, 2023
@mr-cal mr-cal deleted the lxd-interim-release-support branch February 24, 2023 02:00
@jugmac00
Copy link
Member

Quick heads-up - we faced a (short) production regression after deploying these changes, as it looks like that after my review some more changes were made, especially the work around add_remote, which the example section does not cover.

As I have tried the previous state of that branch, my local lxc installation was already configured with the buildd remote (craft-com.ubuntu.cloud-buildd), but in production that failed.

Also, the changelog for 1.8.0 is missing, see #233 and https://github.com/canonical/craft-providers/blob/c6e624516dbb76ff60abfe9a2459bffe288d5e0e/docs/changelog.rst

Thanks to my colleague @lgp171188 we noticed that issue rather quickly, we rolled it back, and I was able to provide a fix for lpcraft.

Anyway, it works now, thanks a lot for your work!

P.S.: And looks like I need some more isolated test environment.

@mr-cal mr-cal mentioned this pull request Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants